clear 
clc

load('CTU_Encrypted_Malware_Traffic')

for i=0:max(Y)
    nums(i+1) = length(find(Y==i));
end

%%

% ind0 = find(Y==0);
% tmp = randperm(length(ind0));
% ind0 = ind0(tmp(1:floor(length(ind0)*0.5)));
% 
% ind2 = find(Y==2);
% tmp = randperm(length(ind2));
% ind2 = ind2(tmp(1:floor(length(ind2)*0.1)));
% 
% ind5 = find(Y==5);
% tmp = randperm(length(ind5));
% ind5 = ind5(tmp(1:floor(length(ind5)*0.2)));
% 
% ind = [ind0; find(Y==1); ind2; find(Y==3); find(Y==4); ind5];
% Y = Y(ind);
% for i=1:length(X)
%     X{i} = X{i}(:,ind);
% end
% 
% save('CTU_Encrypted_Malware_Traffic_sel.mat', 'data_name', 'class_meaning', 'view_meaning', 'X', 'Y', '-v7.3');


%%

% % ind0 = find(Y==0);
% % tmp = randperm(length(ind0));
% % ind0 = ind0(tmp(1:floor(length(ind0)*0.5)));
% 
% ind2 = find(Y==2);
% tmp = randperm(length(ind2));
% ind2 = ind2(tmp(1:floor(length(ind2)*0.1)));
% 
% % ind5 = find(Y==5);
% % tmp = randperm(length(ind5));
% % ind5 = ind5(tmp(1:floor(length(ind5)*0.2)));
% 
% % ind = [ind0; find(Y==1); ind2; find(Y==3); find(Y==4); ind5];
% ind = [find(Y==0); find(Y==1); ind2; find(Y==3); find(Y==4); find(Y==5)];
% Y = Y(ind);
% 
% save('CTU_Encrypted_Malware_Traffic_sel_2.mat', 'data_name', 'class_meaning', 'view_meaning', 'X', 'Y', '-v7.3');

%%

% ind0 = find(Y==0);
% 
% ind1 = find(Y~=1);
% tmp = randperm(length(ind1));
% ind1 = ind1(tmp(1:length(ind0)));
% 
% ind = [ind0; ind1];
% for i=1:length(X)
%     X{i} = X{i}(:,ind);
% end
% Y = [zeros(length(ind0),1); ones(length(ind1),1)];
% 
% class_meaning = {'normal', 'malicious'};
% 
% save('CTU_Encrypted_Malware_Traffic_2_class.mat', 'data_name', 'class_meaning', 'view_meaning', 'X', 'Y', '-v7.3');